package com.my.study.algorithm.leetcode.huwei;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * @author Carlos
 * @version 1.0.0
 * @date 2023/2/28 8:11
 */
public class HuWei {


    public static void main(String[] args) {
       drawNotRepeatNum1();
    }
    
    /**
     * 分割字符
     * 
     * 
     * @param :   
     * @return void
     * @author Carlos
     * @date 2023/3/2 7:25
     */
    private static void strSplit() {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        int len = str.length();
        int splitPoint = 0;
        int start = 0;
        while (splitPoint < len) {
            start = splitPoint;
            splitPoint = start + 8;
            if (splitPoint <= len) {
                System.out.println(str.substring(start, splitPoint));
            }
        }
        
        if (start < len && splitPoint != 8) {
            str = str.substring(start, len);
            for (int i = 0; i < splitPoint - len; i++) {
                str = str + "0";
            }
            System.out.println(str);
        }
    }
    
    /**
     * 十六进制 -> 十进制
     * 
     * @param s:   
     * @return int
     * @author Carlos
     * @date 2023/3/7 7:26
     */
    private static int converter(String s) {
        // 二进制：Binary 八进制：octal 十六进制：hex
        s = s.substring(2);
        int len = s.length();
        int sum = 0;
        for (int i = len - 1; i >= 0 ; i--) {
            char c = s.charAt(i);
            int num = (int) c;
            if (num >= 65) {
                num = num - 65 + 10;
            }
            else {
                num = num - 48;
            }

            sum = sum + (int) Math.pow(16, len - i - 1) * num;
        }
        
        return sum;
    }
    
    /**
     * 找出所以质因数（包括重复数值）
     * 
     * @param num:   
     * @return void
     * @author Carlos
     * @date 2023/3/7 7:27
     */
    private static void primeNum(int num) {
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                System.out.println(i);
                num = num / i;
                i--;
            }
        }
        System.out.println(num);
    }
    
    /**
     * 向下取整
     * 
     * @param :   
     * @return int
     * @author Carlos
     * @date 2023/3/7 7:58
     */
    private static int roundDown() {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] split = s.split("\\.");
        StringBuilder sb = new StringBuilder();
        int res = 0;
        if (split.length >= 2) {
            sb.append(split[0]);
            char c = split[1].toCharArray()[0];
            if (c < '5') {
                res = Integer.parseInt(sb.toString());
            }
            else {
                res = Integer.parseInt(sb.toString()) + 1;
            }
            
        }
        
        return res;
    }
    
    /**
     * 合并表记录
     * 
     * @param :   
     * @return void
     * @author Carlos
     * @date 2023/3/8 7:34
     */
    private static void mergeTableRecord() {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        Map<Integer, Integer> result = new TreeMap<>();
        for (int i = 0; i <= size; i++) {
            String[] split = sc.nextLine().split(" ");
            if (split.length < 2) {
                continue;
            }
            Integer key = Integer.parseInt(split[0]);
            Integer value = Integer.parseInt(split[1]);
            
            result.merge(key, value, Integer::sum);
        }
        
        result.forEach((k, v) -> System.out.println(k + " " + v));
    }
    
    
    /**
     * 输入一个 int 型整数，按照从右向左的阅读顺序，返回一个不含重复数字的新的整数。
     * 保证输入的整数最后一位不是 0 。
     * 
     * @param :   
     * @return void
     * @author Carlos
     * @date 2023/3/8 8:07
     */
    private static void drawNotRepeatNum() {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        StringBuilder sb = new StringBuilder(str).reverse();
        str = sb.toString();
        
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < str.length(); i++) {
            int indexOf = str.indexOf(str.charAt(i));
            if (indexOf == i && i != 0) {
                result.append(str.charAt(i));
            }
        }
        System.out.println(result.toString());
    }

    /**
     * 输入一个 int 型整数，按照从右向左的阅读顺序，返回一个不含重复数字的新的整数。
     * 保证输入的整数最后一位不是 0 。
     *
     * @param :   
     * @return void
     * @author Carlos
     * @date 2023/3/8 8:07
     */
    private static void drawNotRepeatNum1() {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (result.lastIndexOf(String.valueOf(c)) != -1) {
                continue;
            }
            result.append(c);
        }
        System.out.println(result.toString());
    }
    
}
